
/******************************************************************************
*
*               Copyright Mentor Graphics Corporation 2003
*                           All rights reserved
*
*   THIS WORK CONTAINS TRADE SECRETS AND PROPRIETARY INFORMATION WHICH IS
*    THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS
*                        SUBJECT TO LICENSE TERMS
*
*******************************************************************************

*******************************************************************************
* FILE NAME                                                          VERSION
* act_function_pointer_test.c                                        1.1
*
* COMPONENT
* ANSI/ISO C test application
*
* DESCRIPTION
* Demonstrates the use of pointer's to a function.
*
* FUNCTIONS
* int act_function_pointer_test(int value)
*
* DEPENDENCIES
* act_test.h
******************************************************************************/
#include "act_test.h"

#if (ACT_FUNCTION_POINTER_TEST)

struct TestStruct
{
     char   a;
     short  b;
     int    c;
};


/*global variable that is a pointer to a function.*/
int (*g_pFunction)(int param1, char param2, struct TestStruct* param3);


/***************************************************************************/

int Function_1(int param1, char param2, struct TestStruct* param3)
{
     return( ++param1 );
}



int Function_2(int param1, char param2, struct TestStruct* param3)
{
     return( param1 + 2 );
}



/******************************************************************************
* FUNCTION
* int act_function_pointer_test(int value)
*
* DESCRIPTION
* Demonstrates the use of pointer's to a function.
*
* INPUTS
* int value                     Counter value from ansi_c_test(..) in act.c
*
* OUTPUTS
* int                           returns Ret_Value from function call.
******************************************************************************/
int act_function_pointer_test(int value)
{
     struct TestStruct s;
     int Ret_Value;
     int (*pFunction)(int,char,struct TestStruct*); /*  local pointer to function */

     g_pFunction = Function_1;
     Ret_Value = g_pFunction(5,'c',&s);

     pFunction = Function_2;

     g_pFunction = pFunction;

     Ret_Value += pFunction(Ret_Value,'f',&s);

     return Ret_Value;
}

#endif




